#!/bin/sh

# Create the root directory and geth / metrics directories
sudo mkdir {{ paths.root }}
sudo mkdir {{ paths.root }}/{ethereum,prometheus}

# Create all the data directories for the bees to store their tasty honey
{% for i in range(num_nodes) %}
sudo mkdir {{ paths.root }}/bee-{{ loop.index }}
sudo chown 999:999 {{ paths.root }}/bee-{{ loop.index }}
sudo chmod 755 {{ paths.root }}/bee-{{ loop.index }}
{% endfor %}

# Let's setup clef to make sure it does it's job co-ordinating for our bees
sudo mkdir -p {{ paths.root }}/clef/keystore
sudo mv UTC* {{ paths.root }}/clef/keystore/
sudo cp password {{ paths.root }}/clef/password
sudo chown 65534:0 -R {{ paths.root }}/clef
sudo chmod 750 {{ paths.root }}/clef
sudo chmod 0600 {{ paths.root }}/clef/keystore/UTC*
sudo sh clef.sh

sudo mv password {{ paths.root }}/password

# Setup permissions for metrics gathering
sudo chown 65534:65534 {{ paths.root }}/prometheus
sudo chmod 755 {{ paths.root }}/prometheus
sudo chmod 777 {{ paths.root }}/password

chmod +x monBee.sh

docker-compose up -d

cat tearsheet.txt